<!doctype html>
<html>
 <head>
  <script src="https://unpkg.com/dexie@latest/dist/dexie.js"></script>
  <script>
   //
   // Declare Database
   //
   var db = new Dexie("FriendDatabase");
   db.version(1).stores({
    // 这里会把第一个索引：++id 默认设置为主键
    
    //  friends: "++id,name,age"
    //  friends: "name,age"  // 如果这样的话：name就会成为主键

     friends: "[name+age],name,age"  // 如果这样的话：[name+age]就会成为主键
   });

   //
   // Manipulate and Query Database
   //
   db.friends.add({name: "Josephine", age: "21"}).then(function() {
       return db.friends.where("age").below("25").toArray();
   }).then(function (youngFriends) {
       alert ("My young friends: " + JSON.stringify(youngFriends));
   }).catch(function (e) {
       alert ("Error: " + (e.stack || e));
   });
  </script>
 </head>
</html>

<!-- 
    表名：FriendDatabase
    table名：friends
    索引：[name+age]
    列：name，age
 -->